<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
    <yks-equipment-devops-service-form ref="realForm" @ok="submitCallback" :EquipmentId="currentEquipmentId" :isHistory="isHistory" :disabled="disableSubmit"/>
    <template slot="footer">
      <a-button v-if="isHistory?false:!disableSubmit" @click="handleOk" shape="round" style="width: 99px" type="primary">保存草稿</a-button>
      <a-button v-if="isHistory?false:!disableSubmit" @click="myHandleOk" type="primary" shape="round" >提交审核</a-button>
      <a-button v-if="isHistory" @click="myHandleOk" type="primary" shape="round" >保养完成</a-button>
    </template>
  </j-modal>
</template>


<script>

  import YksEquipmentDevopsServiceForm from './YksEquipmentDevopsServiceForm'

  export default {
    name: 'YksEquipmentDevopsServiceModal',
    components: {
      YksEquipmentDevopsServiceForm
    },
    data() {
      return {
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        isHistory:false,
        currentEquipmentId:'',
        serviceType:'',
        disableButton: false,
      }
    },
    created() {
    },
    methods:{
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.currentEquipmentId = this.currentEquipmentId
          this.$refs.realForm.serviceType = this.serviceType
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.currentEquipmentId = this.currentEquipmentId
          this.$refs.realForm.serviceType = this.serviceType
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      myHandleOk () {
        this.$refs.realForm.dataStatus = '2' //提交审核
        this.$refs.realForm.handleOk();
      },
      handleOk () {
        this.$refs.realForm.dataStatus = '1' //草稿
        this.$refs.realForm.handleOk();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>

<style scoped>
</style>